package com.zhidisoft.system.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.zhidisoft.base.dao.impl.BaseDaoImpl;
import com.zhidisoft.system.dao.IRoleDao;
import com.zhidisoft.system.entity.Role;

/**
 * 角色数据库操作实现
 * @author Lu jianliang
 *
 */
@Repository
public class RoleDaoImpl extends BaseDaoImpl<Role, String> implements IRoleDao{

	public RoleDaoImpl(){
		super(Role.class);
	}

	@Override
	public List<Role> findByUserId(String userId) {
		
		return this.find("from Role r join fetch r.users u where u.id=? order by r.sortNum", userId);
	}

	@Override
	public List<Role> findByPage(Long pageNumber, Long pageSize) {
		
		return this.findByPage(pageNumber.intValue(), pageSize.intValue(), "from Role r left join fetch r.functions left join fetch r.createUser left join fetch r.updateUser order by r.sortNum",new Object[]{});
	}
}
